package online.afeibaili.storebackendframework.other

import online.afeibaili.storebackendframework.af.CouponInterface
import online.afeibaili.storebackendframework.model.json.CouponJsonMapper
import online.afeibaili.storebackendframework.service.impl.AccountServiceImpl
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.stereotype.Component


/**
 * 优惠券插入接口
 *
 *@author AfeiBaili
 *@version 2025/11/6 10:31
 */

@Component
class CouponInterfaceImpl : CouponInterface {

    @Autowired
    lateinit var accountServiceImpl: AccountServiceImpl

    override fun insertCoupon(couponId: String, userId: String): Boolean? {
        return accountServiceImpl.addCoupons(
            userId,
            listOf(CouponJsonMapper(couponId.toLong(), System.currentTimeMillis(), 1))
        )
    }
}